Calendar All Tests
Current file: /home/estudydev/workspace/eStudy_svn/web/teams/classes/class.teamlist.inc.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 6
0.00 %0.00%
0.00% 0 / 70
 
TeamList
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 6
0.00 %0.00%
0.00% 0 / 70
 public function listTeams($teams)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 30
 public function getTeams($courseID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 12
 public function countTeams($courseID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 5
 public function showDateForm($courseID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 12
 public function getTeamClosingDate($courseID)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 5
 public function setTeamClosingDate($courseID, $timestamp)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 6


       1                 : <?php                                                                                                                                                                                                                                                                                                                 
       2                 : /*--------------------------------------------------------------------------+                                                                                                                                                                                                                                         
       3                 :  This file is part of eStudy.                                                                                                                                                                                                                                                                                         
       4                 :  teams/classes/class.teamlist.inc.php                                                                                                                                                                                                                                                                                 
       5                 :  - Modulgruppe:  Teams                                                                                                                                                                                                                                                                                                
       6                 :  - Beschreibung: Klasse zum Auflisten von Teams in Kursen.                                                                                                                                                                                                                                                            
       7                 :  - Version:      0.3, 18/11/06                                                                                                                                                                                                                                                                                        
       8                 :  - Autor(en):    Clemens Weiß <clemens.weiss@mni.fh-giessen.de>                                                                                                                                                                                                                                                      
       9                 :  +---------------------------------------------------------------------------+                                                                                                                                                                                                                                        
      10                 :  This program is free software; you can redistribute it and/or                                                                                                                                                                                                                                                        
      11                 :  modify it under the terms of the GNU General Public License                                                                                                                                                                                                                                                          
      12                 :  as published by the Free Software Foundation; either version 2                                                                                                                                                                                                                                                       
      13                 :  of the License, or any later version.                                                                                                                                                                                                                                                                                
      14                 :  +---------------------------------------------------------------------------+                                                                                                                                                                                                                                        
      15                 :  This program is distributed in the hope that it will be useful,                                                                                                                                                                                                                                                      
      16                 :  but WITHOUT ANY WARRANTY; without even the implied warranty of                                                                                                                                                                                                                                                       
      17                 :  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                                                                                                                                                                                                                                        
      18                 :  GNU General Public License for more details.                                                                                                                                                                                                                                                                         
      19                 :  You should have received a copy of the GNU General Public License                                                                                                                                                                                                                                                    
      20                 :  along with this program; if not, write to the Free Software                                                                                                                                                                                                                                                          
      21                 :  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                                                                                                                                                                                                                                          
      22                 :  +--------------------------------------------------------------------------*/                                                                                                                                                                                                                                        
      23                 : /**                                                                                                                                                                                                                                                                                                                   
      24                 :  * Klasse zum Auflisten von Teams in Kursen.                                                                                                                                                                                                                                                                          
      25                 :  * @package eStudy.Teams                                                                                                                                                                                                                                                                                              
      26                 :  * @version 0.3, 18/11/06                                                                                                                                                                                                                                                                                             
      27                 :  * @author Clemens Weiß <clemens.weiss@mni.fh-giessen.de>                                                                                                                                                                                                                                                            
      28                 :  */                                                                                                                                                                                                                                                                                                                   
      29                 : if(! defined("PATH_TO_ROOT")) define("PATH_TO_ROOT","../../");                                                                                                                                                                                                                                                        
      30                 : require_once (PATH_TO_ROOT."teams/classes/class.team.inc.php");                                                                                                                                                                                                                                                       
      31                 : require_once (PATH_TO_ROOT."common/classes/class.dateselection.inc.php");                                                                                                                                                                                                                                             
      32                 : require_once (PATH_TO_ROOT."common/classes/class.data.inc.php");                                                                                                                                                                                                                                                      
      33                 : require_once (PATH_TO_ROOT."common/classes/class.output.inc.php");                                                                                                                                                                                                                                                    
      34                 : require_once (PATH_TO_ROOT."common/classes/class.utilities.inc.php");                                                                                                                                                                                                                                                 
      35                 : class TeamList {                                                                                                                                                                                                                                                                                                      
      36                 :     /**                                                                                                                                                                                                                                                                                                               
      37                 :      * Gibt ein Formular aus, in dem alle angelegten Teams bearbeitet werden können                                                                                                                                                                                                                                  
      38                 :      * mit einer leeren Zeile zum Neuanlegen.                                                                                                                                                                                                                                                                         
      39                 :      *                                                                                                                                                                                                                                                                                                                
      40                 :      * @static                                                                                                                                                                                                                                                                                                        
      41                 :      * @access public                                                                                                                                                                                                                                                                                                 
      42                 :      * @param array $teams Array von Team-Objekten                                                                                                                                                                                                                                                                    
      43                 :      * @return bool false bei fehlerhaftem Array, sonst true                                                                                                                                                                                                                                                          
      44                 :      */                                                                                                                                                                                                                                                                                                               
      45                 :     function listTeams($teams) {                                                                                                                                                                                                                                                                                      
      46               0 :         if (!is_array($teams)) {                                                                                                                                                                                                                                                                                      
      47               0 :             return false;                                                                                                                                                                                                                                                                                             
      48                 :         }                                                                                                                                                                                                                                                                                                             
      49               0 :         foreach($teams as $team) {                                                                                                                                                                                                                                                                                    
      50               0 :             if (!is_a($team, "Team")) return false;                                                                                                                                                                                                                                                                   
      51               0 :         }                                                                                                                                                                                                                                                                                                             
      52               0 :         if (!(isset($teams[0]) && $teams[0]->getID() == 0)) {                                                                                                                                                                                                                                                         
      53                 :             // wenn gerade ein neues Team angelegt werden soll, die Eingabe aber noch Fehler enthält,                                                                                                                                                                                                                
      54                 :             // keine Zeile für ein weiteres neues Team anfügen                                                                                                                                                                                                                                                      
      55               0 :             $teams[0] = new Team(0);                                                                                                                                                                                                                                                                                  
      56               0 :         }                                                                                                                                                                                                                                                                                                             
      57               0 :         echo "<h2>Teams in diesem Kurs</h2>";                                                                                                                                                                                                                                                                         
      58               0 :         echo "<form action='".PATH_TO_ROOT.SCRIPT_NAME."' method='post'>";                                                                                                                                                                                                                                            
      59               0 :         echo "<table class='tableBorder'>\n";                                                                                                                                                                                                                                                                         
      60               0 :         echo "<tr class='tableHead'>";                                                                                                                                                                                                                                                                                
      61               0 :         echo "<th>L&ouml;schen&nbsp;".Utilities::helpCode(500) ."</th>";                                                                                                                                                                                                                                              
      62               0 :         echo "<th>Name ".Utilities::helpCode(501) ."</th>";                                                                                                                                                                                                                                                           
      63               0 :         echo "<th>Mitgl.&nbsp;".Utilities::helpCode(502) ."</th>";                                                                                                                                                                                                                                                    
      64               0 :         echo "<th>Team-Style ".Utilities::helpCode(503) ."</th>";                                                                                                                                                                                                                                                     
      65               0 :         echo "<th>Team-Logo ".Utilities::helpCode(504) ."</th>";                                                                                                                                                                                                                                                      
      66               0 :         echo "</tr>\n";                                                                                                                                                                                                                                                                                               
      67               0 :         foreach($teams as $teamID => $team) {                                                                                                                                                                                                                                                                         
      68               0 :             $data = null;                                                                                                                                                                                                                                                                                             
      69               0 :             if (isset($_POST["name$teamID"]) && $teamID > 0) {                                                                                                                                                                                                                                                        
      70               0 :                 $data = array("name" => $_POST["name$teamID"], "maxMembers" => $_POST["maxMembers$teamID"], "style" => $_POST["style$teamID"], "logo" => $_POST["logo$teamID"]);                                                                                                                                      
      71               0 :             }                                                                                                                                                                                                                                                                                                         
      72               0 :             $formRow = $team->getFormRow($data);                                                                                                                                                                                                                                                                      
      73               0 :             echo $formRow;                                                                                                                                                                                                                                                                                            
      74               0 :         }                                                                                                                                                                                                                                                                                                             
      75               0 :         Output::echoDialogBottom(array("okButton" => "Speichern", "cancelButton" => "",), 5);                                                                                                                                                                                                                         
      76               0 :         echo "</table>\n";                                                                                                                                                                                                                                                                                            
      77               0 :         echo "</form>";                                                                                                                                                                                                                                                                                               
      78               0 :         return true;                                                                                                                                                                                                                                                                                                  
      79                 :     }                                                                                                                                                                                                                                                                                                                 
      80                 :     /**                                                                                                                                                                                                                                                                                                               
      81                 :      * Gibt ein Array mit Team-Objekten für den angegebenen Kurs zurück.                                                                                                                                                                                                                                            
      82                 :      *                                                                                                                                                                                                                                                                                                                
      83                 :      * @static                                                                                                                                                                                                                                                                                                        
      84                 :      * @access public                                                                                                                                                                                                                                                                                                 
      85                 :      * @param int $courseID ID des Kurses                                                                                                                                                                                                                                                                             
      86                 :      * @return mixed false, wenn die Kurs-ID ungültig ist, sonst ein Array mit Team-Objekten                                                                                                                                                                                                                         
      87                 :      */                                                                                                                                                                                                                                                                                                               
      88                 :     function getTeams($courseID) {                                                                                                                                                                                                                                                                                    
      89               0 :         global $db, $settings;                                                                                                                                                                                                                                                                                        
      90               0 :         $dbp = $settings["dbPrefix"];                                                                                                                                                                                                                                                                                 
      91               0 :         if (strval(intval($courseID)) != $courseID || $courseID < 0) {                                                                                                                                                                                                                                                
      92               0 :             return false;                                                                                                                                                                                                                                                                                             
      93                 :         }                                                                                                                                                                                                                                                                                                             
      94               0 :         $teams = array();                                                                                                                                                                                                                                                                                             
      95               0 :         $teamIDs = $db->get_col("SELECT id FROM {$dbp}teams WHERE course_id='$courseID' ORDER BY name");                                                                                                                                                                                                              
      96               0 :         if (!empty($teamIDs)) {                                                                                                                                                                                                                                                                                       
      97               0 :             foreach($teamIDs as $teamID) {                                                                                                                                                                                                                                                                            
      98               0 :                 $teams[(int)$teamID] = new Team($teamID);                                                                                                                                                                                                                                                             
      99               0 :             }                                                                                                                                                                                                                                                                                                         
     100               0 :         }                                                                                                                                                                                                                                                                                                             
     101               0 :         return $teams;                                                                                                                                                                                                                                                                                                
     102                 :     }                                                                                                                                                                                                                                                                                                                 
     103                 :     /**                                                                                                                                                                                                                                                                                                               
     104                 :      * Gibt die Anzahl der Teams für den angegebenen Kurs zurück                                                                                                                                                                                                                                                    
     105                 :      *                                                                                                                                                                                                                                                                                                                
     106                 :      * @static                                                                                                                                                                                                                                                                                                        
     107                 :      * @access public                                                                                                                                                                                                                                                                                                 
     108                 :      * @param int $courseID ID des Kurses                                                                                                                                                                                                                                                                             
     109                 :      * @return mixed int Anzahl der Teams oder false bei ungültiger Kurs-ID                                                                                                                                                                                                                                          
     110                 :      */                                                                                                                                                                                                                                                                                                               
     111                 :     function countTeams($courseID) {                                                                                                                                                                                                                                                                                  
     112               0 :         global $db, $settings;                                                                                                                                                                                                                                                                                        
     113               0 :         $dbp = $settings["dbPrefix"];                                                                                                                                                                                                                                                                                 
     114               0 :         if (strval(intval($courseID)) != $courseID || $courseID < 0) {                                                                                                                                                                                                                                                
     115               0 :             return false;                                                                                                                                                                                                                                                                                             
     116                 :         }                                                                                                                                                                                                                                                                                                             
     117               0 :         return (int)$db->get_var("SELECT COUNT(*) FROM {$dbp}teams WHERE course_id='$courseID'");                                                                                                                                                                                                                     
     118                 :     }                                                                                                                                                                                                                                                                                                                 
     119                 :     /**                                                                                                                                                                                                                                                                                                               
     120                 :      *                                                                                                                                                                                                                                                                                                                
     121                 :      */                                                                                                                                                                                                                                                                                                               
     122                 :     function showDateForm($courseID) {                                                                                                                                                                                                                                                                                
     123               0 :         $timestamp = TeamList::getTeamClosingDate($courseID);                                                                                                                                                                                                                                                         
     124               0 :         if ($timestamp <= 0) {                                                                                                                                                                                                                                                                                        
     125               0 :             $timestamp = time();                                                                                                                                                                                                                                                                                      
     126               0 :         }                                                                                                                                                                                                                                                                                                             
     127               0 :         $ds = new DateSelection(date("d", $timestamp), date("m", $timestamp), date("Y", $timestamp));                                                                                                                                                                                                                 
     128               0 :         $ds->clearStrings();                                                                                                                                                                                                                                                                                          
     129               0 :         echo "<p>W&auml;hlen Sie hier aus, bis zu welchem Datum die Kursteilnehmer ihre Teamauswahl noch &auml;ndern k&ouml;nnen. Nach diesem Zeitpunkt k&ouml;nnen sich die Mitglieder zwar noch f&uuml;r ein Team entscheiden, die Team-Zuordnung kann danach aber nur noch vom Dozenten ge&auml;ndert werden.</p>";
     130               0 :         echo "<form action='".PATH_TO_ROOT.SCRIPT_NAME."' method='post'>";                                                                                                                                                                                                                                            
     131               0 :         $ds->printCalender("date", "dateExt");                                                                                                                                                                                                                                                                        
     132               0 :         echo " <input type='submit' name='saveDate' value='Speichern' />";                                                                                                                                                                                                                                            
     133               0 :         echo "</form>";                                                                                                                                                                                                                                                                                               
     134               0 :     }                                                                                                                                                                                                                                                                                                                 
     135                 :     function getTeamClosingDate($courseID) {                                                                                                                                                                                                                                                                          
     136               0 :         global $db, $settings;                                                                                                                                                                                                                                                                                        
     137               0 :         $dbp = $settings["dbPrefix"];                                                                                                                                                                                                                                                                                 
     138               0 :         if (strval(intval($courseID)) != $courseID || $courseID <= 0) {                                                                                                                                                                                                                                               
     139               0 :             return 0;                                                                                                                                                                                                                                                                                                 
     140                 :         }                                                                                                                                                                                                                                                                                                             
     141               0 :         return (int)$db->get_var("SELECT team_closing_date FROM {$dbp}courses WHERE ID='$courseID'");                                                                                                                                                                                                                 
     142                 :     }                                                                                                                                                                                                                                                                                                                 
     143                 :     function setTeamClosingDate($courseID, $timestamp) {                                                                                                                                                                                                                                                              
     144               0 :         global $db, $settings, $EZSQL_ERROR;                                                                                                                                                                                                                                                                          
     145               0 :         $dbp = $settings["dbPrefix"];                                                                                                                                                                                                                                                                                 
     146               0 :         if (strval(intval($courseID)) != $courseID || $courseID <= 0 || strval(intval($timestamp)) != $timestamp) {                                                                                                                                                                                                   
     147               0 :             return false;                                                                                                                                                                                                                                                                                             
     148                 :         }                                                                                                                                                                                                                                                                                                             
     149               0 :         $db->query("UPDATE {$dbp}courses SET team_closing_date='$timestamp' WHERE ID='$courseID'");                                                                                                                                                                                                                   
     150               0 :         return $db->rows_affected == 1;                                                                                                                                                                                                                                                                               
     151                 :     }                                                                                                                                                                                                                                                                                                                 
     152                 : }                                                                                                                                                                                                                                                                                                                     
     153                 :                                                                                                                                                                                                                                                                                                                       
     154                 :                                                                                                                                                                                                                                                                                                                       

Generated by PHPUnit 3.2.21 and Xdebug 2.0.3 at Thu Nov 26 17:01:15 CET 2009.